package com.quanyan.signup.web;

import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.signup.entity.db.TbExpertUser;
import com.quanyan.signup.entity.db.TbReferUser;
import com.quanyan.signup.entity.vo.req.ReqSerchReferUser;
import com.quanyan.signup.entity.vo.resp.RespMyReferUser;
import com.quanyan.signup.service.SignUpAdminService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/7/7.
 */
@RestController
@RequestMapping(value = "admin/api/signup")
public class SignUpAdminController {

    private static final Logger LOGGER = LoggerFactory.getLogger(SignUpAdminController.class);

    @Autowired
    private SignUpAdminService signUpAdminService;

    /**
     * 达人管理界面访问及条件查询
     * @param reqSerchReferUser
     * @return
     */
    @RequestMapping(value = "tbExpertUserMessage",method = RequestMethod.POST)
    public APIResponse<PageObj<List<TbExpertUser>>> tbExpertUserMessage(@RequestBody ReqSerchReferUser reqSerchReferUser){
        LOGGER.debug("--------tbExpertUserMessage------begin-----");
        return signUpAdminService.getExpertUserMsg(reqSerchReferUser);
    }

    /**
     * 达人管理查询结果导出
     * @param reqSerchReferUser
     * @return
     */
    @RequestMapping(value = "exportExpertUserMsg",method = RequestMethod.POST)
    public APIResponse<List<TbExpertUser>> exportExpertUserMsg(@RequestBody ReqSerchReferUser reqSerchReferUser){
        LOGGER.debug("--------exportExpertUserMsg------begin-----");
        return signUpAdminService.exportExpertUserMsg(reqSerchReferUser);
    }

    /**
     * 修改达人状态
     * @param map
     * @return
     */
    @RequestMapping(value = "setSignStatu",method = RequestMethod.POST)
    public APIResponse setSignStatu(@RequestBody Map<String,Object> map){
       LOGGER.debug("--------setSignStatu------begin-----");
       return signUpAdminService.setSignStatu(map);
    }

    /**
     * 删除达人
     * @param map
     * @return
     */
    @RequestMapping(value = "delExpertUser",method = RequestMethod.POST)
    public APIResponse delExpertUser(@RequestBody Map<String,Object> map){
        LOGGER.debug("--------delExpertUser------begin-----");
        return signUpAdminService.delExpertUser((String) map.get("mobile"));
    }

    /**
     * 面试录入结果
     * @param map
     * @return
     */
    @RequestMapping(value = "insertInterviewResult",method = RequestMethod.POST)
    public APIResponse insertInterviewResult(@RequestBody Map<String,Object> map){
        LOGGER.debug("--------insertInterviewResult------begin-----");
        return signUpAdminService.insertInterviewResult(map);
    }

    /**
     * 分页查询所以推荐人信息及条件搜索
     * @param reqSerchReferUser
     * @return
     */
    @RequestMapping(value = "getReferUserMsg",method = RequestMethod.POST)
    public APIResponse<PageObj<List<TbReferUser>>> getReferUserMsg(@RequestBody ReqSerchReferUser reqSerchReferUser){
        LOGGER.debug("--------getReferUserMsg------begin-----");
        return signUpAdminService.getReferUserMsg(reqSerchReferUser);
    }

    /**
     * 分页查询所有推荐人信息及条件搜索，结果导出
     * @param reqSerchReferUser
     * @return
     */
    @RequestMapping(value = "exportReferUserMsg",method = RequestMethod.POST)
    public APIResponse<List<TbReferUser>> exportReferUserMsg(@RequestBody ReqSerchReferUser reqSerchReferUser){
        LOGGER.debug("--------exportReferUserMsg------begin-----");
        return signUpAdminService.exportReferUserMsg(reqSerchReferUser);
    }


    /**
     * 分页查询推荐人推荐所有达人信息
     * @param reqSerchReferUser
     * @return
     */
    @RequestMapping(value = "getMyExpertUserMsg",method = RequestMethod.POST)
    public APIResponse<RespMyReferUser> getMyExpertUserMsg(@RequestBody ReqSerchReferUser reqSerchReferUser){
        LOGGER.debug("--------getMyExpertUserMsg------begin-----");
        return signUpAdminService.getMyExpertUserMsg(reqSerchReferUser);
    }

    /**
     * 确定推荐人已提现
     * @param map
     * @return
     */
    @RequestMapping(value = "confirmReferMoney",method = RequestMethod.POST)
    public APIResponse confirmReferMoney(@RequestBody Map<String,Object> map){
        LOGGER.debug("--------confirmReferMoney------begin-----");
        return signUpAdminService.confirmReferMoney((String) map.get("mobile"));
    }

    /**
     * 达人编辑页面
     * @param map
     * @return
     */
    @RequestMapping(value = "editExpertInfo",method = RequestMethod.POST)
    public APIResponse<TbExpertUser> editExpertInfo(@RequestBody Map<String,Object> map){
        LOGGER.debug("--------editExpertInfo------begin-----");
        return signUpAdminService.editExpertInfo((Integer) map.get("id"));
    }

    /**
     * 跟新达人信息
     * @param map
     * @return
     */
    @RequestMapping(value = "updateExpertInfo",method = RequestMethod.POST)
    public APIResponse updateExpertInfo(@RequestBody Map<String,Object> map){
        LOGGER.debug("--------updateExpertInfo------begin-----");
        return signUpAdminService.updateExpertInfo((Integer) map.get("id"),(String)map.get("name"),(String)map.get("photoUrl"));
    }

}
